package com.project.dao.impl;

import com.project.server.Request;

import java.sql.*;

public class BaseDao {

    protected Connection con;

    protected PreparedStatement ps;

    protected ResultSet rs;


    public void setConnection(){

        try {
            Class.forName("com.mysql.jdbc.Driver");
            con= DriverManager.getConnection("jdbc:mysql://localhost:12345/hw?characterEncoding=utf-8",
                    "root","lovo");

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
 public void close(){

     try {
         if (rs!=null){
             rs.close();
         }
         if (ps!=null){
             ps.close();
         }
         if (con!=null){
             con.close();
         }
     } catch (SQLException e) {
         throw new RuntimeException(e);
     }

 }
}
